package com.dzsw.rabbitmq.controller;

import com.dzsw.rabbitmq.service.IRabbitMQService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequestMapping("/rabbit")
public class RabbitMQController {

    @Resource
    private IRabbitMQService rabbitMQService;

    @GetMapping(value = "/sendFanout")
    public String sendMsg(){
        rabbitMQService.send2FanoutTestQueue("this is a test fanout message!");
        return "ok!";
    }

    @GetMapping(value = "/sendDirect")
    public String sendDirectMsg(){
        rabbitMQService.send2DirectTestQueue("this is a test direct message!");
        return "ok!";
    }

    @GetMapping(value = "/sendTopicA")
    public String sendTopicAMsg(){
        rabbitMQService.send2TopicTestAQueue("this is a test topic aaa message!");
        return "ok!";
    }

    @GetMapping(value = "/sendTopicB")
    public String sendTopicBMsg(){
        rabbitMQService.send2TopicTestBQueue("this is a test topic bbb message!");
        return "ok!";
    }
}
